package com.cnhis.drgs.core.util;


import org.apache.commons.io.IOUtils;

import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {
    /**
     * 加载properties配置文件
     *
     * @param classPathFileName classpath下的文件一般/开头 eg:/config.properties
     */
    public static Properties loadProperties(String classPathFileName) {
        return loadProperties(PropertiesUtil.class.getResourceAsStream(classPathFileName));
    }

    /**
     * 加载properties配置文件
     *
     * @param is
     * @return
     */
    public static Properties loadProperties(InputStream is) {
        try {
            Properties properties = new Properties();
            properties.load(is);
            return properties;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(is);
        }
        return null;
    }
}
